@@ -171,6 +171,39 @@ module.exports = {
171
171
SyntaxError
172
172
) ;
173
173
174
+ // partial padding
175
+ s2t [ 'throws' ] (
176
+ function ( ) { method ( 'ZXhhZg=' ) ; } ,
177
+ SyntaxError
178
+ ) ;
179
+ s2t [ 'throws' ] (
180
+ function ( ) { method ( 'ZXhhZg=' , { lastChunkHandling : 'loose' } ) ; } ,
181
+ SyntaxError
182
+ ) ;
183
+ s2t . deepEqual ( method ( 'ZXhhZg=' , { lastChunkHandling : 'stop-before-partial' } ) , new Uint8Array ( [ 101 , 120 , 97 ] ) ) ;
184
+ s2t [ 'throws' ] (
185
+ function ( ) { method ( 'ZXhhZg=' , { lastChunkHandling : 'strict' } ) ; } ,
186
+ SyntaxError
187
+ ) ;
188
+
189
+ // excess padding
190
+ s2t [ 'throws' ] (
191
+ function ( ) { method ( 'ZXhhZg===' ) ; } ,
192
+ SyntaxError
193
+ ) ;
194
+ s2t [ 'throws' ] (
195
+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'loose' } ) ; } ,
196
+ SyntaxError
197
+ ) ;
198
+ s2t [ 'throws' ] (
199
+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'stop-before-partial' } ) ; } ,
200
+ SyntaxError
201
+ ) ;
202
+ s2t [ 'throws' ] (
203
+ function ( ) { method ( 'ZXhhZg===' , { lastChunkHandling : 'strict' } ) ; } ,
204
+ SyntaxError
205
+ ) ;
206
+
174
207
s2t . end ( ) ;
175
208
} ) ;
176
209
@@ -194,6 +227,16 @@ module.exports = {
194
227
) ;
195
228
s2t . deepEqual ( results ( ) , [ ] ) ;
196
229
230
+ s2t [ 'throws' ] (
231
+ function ( ) { method ( 'Zg==' , { alphabet : Object ( 'base64' ) } ) ; } ,
232
+ TypeError
233
+ ) ;
234
+
235
+ s2t [ 'throws' ] (
236
+ function ( ) { method ( 'Zg==' , { lastChunkHandling : Object ( 'loose' ) } ) ; } ,
237
+ TypeError
238
+ ) ;
239
+
197
240
s2t . test ( 'getters' , { skip : ! defineProperties . supportsDescriptors } , function ( s3t ) {
198
241
var base64UrlOptions = { } ;
199
242
var alphabetResults = s3t . intercept ( base64UrlOptions , 'alphabet' , { get : function ( ) { return 'base64url' ; } } ) ;
@@ -246,6 +289,7 @@ module.exports = {
246
289
forEach ( standardBase64Vectors , function ( pair ) {
247
290
var arr = method ( pair [ 0 ] ) ;
248
291
s2t . equal ( getProto ( arr ) , Uint8Array . prototype , 'decoding ' + pair [ 0 ] ) ;
292
+ s2t . equal ( arr . buffer . byteLength , pair [ 1 ] . length , 'decoding ' + pair [ 0 ] ) ;
249
293
s2t . deepEqual ( arr , new Uint8Array ( pair [ 1 ] ) , 'decoding ' + pair [ 0 ] ) ;
250
294
} ) ;
251
295
@@ -303,6 +347,9 @@ module.exports = {
303
347
] ;
304
348
forEach ( whitespaceKinds , function ( pair ) {
305
349
var arr = method ( pair [ 0 ] ) ;
350
+
351
+ s2t . equal ( arr . length , 1 ) ;
352
+ s2t . equal ( arr . buffer . byteLength , 1 ) ;
306
353
s2t . deepEqual ( arr , new Uint8Array ( [ 102 ] ) , 'ascii whitespace: ' + pair [ 1 ] ) ;
307
354
} ) ;
308
355
0 commit comments